import java.util.LinkedList;
import java.util.Queue;
import java.util.Stack;

public class test2 {
    public boolean isCompleteTree(TreeNode root) {
        Stack<TreeNode>stack=new Stack<>();
        TreeNode cur=root;
        while (cur!=null||!stack.isEmpty() ){
            while (cur!=null){
                stack.add(cur);
                cur=cur.left;
            }
            TreeNode cut=stack.pop();
            if (cut.rihgt!=null) {
                stack.add(cut.rihgt);
                return false;
            }
            cur=cut.rihgt;
        }
        if(!stack.isEmpty())return false;
        return true;
    }
}
